home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / unapplied / shadowbug < prev    next >
Text File  |  1995-02-13  |  4KB  |  166 lines

  1. Intersect bug:
  2. AddToHitList adds the object to the hitlist without checking
  3. if there is room in the hitlist->data array.
  4.  
  5. Shadowcache bug:
  6. There is a problem if a CSG object or an animated object is
  7. put in the shadowcache. If the cached object is used in the
  8. next Shadowed() call, TRUE is returned if the object is hit.
  9. This can be wrong, because parts of the object may be transparent.
  10. The following scene will show the bug:
  11.  
  12. surface glass
  13. ambient .02 .02 .02
  14. diffuse 0.1 0.1 0.1
  15. specular 0.8 0.8 0.8 specpow 200
  16. transp 1. index 1.2 extinct 0.98
  17.  
  18. screen 200 150
  19. eyep -20 30 10
  20. lookp 0 0 0
  21. fov 50
  22. light 1 directional -30 0 50
  23. background .3 0 .4
  24. shutter 1
  25.  
  26. list
  27. sphere glass 3  3 0 -3
  28. sphere  3  3 0  6
  29. end
  30. translate (time) 0 0
  31. plane 0 0 -12 0 0 1
  32.  
  33.  
  34. ======================= cut here ========================
  35.  
  36. *** intersect.c.orig    Wed Jun 17 17:36:47 1992
  37. --- intersect.c    Wed Jun 17 17:38:51 1992
  38. ***************
  39. *** 139,146 ****
  40.   {
  41.       HitNode *np;
  42.       Trans *list;
  43.   
  44. !     np = &hitlist->data[hitlist->nodes++];
  45.   
  46.       np->ray = *ray;
  47.       np->obj = obj;
  48. --- 139,150 ----
  49.   {
  50.       HitNode *np;
  51.       Trans *list;
  52. +     int i;
  53.   
  54. !     np = &hitlist->data[i = hitlist->nodes++];
  55. !     if (i >= MAXMODELDEPTH)
  56. !         RLerror(RL_ABORT, "HitList full. Increase libray/libobj/geom.h:MAXMODELDEPTH.\n");
  57.   
  58.       np->ray = *ray;
  59.       np->obj = obj;
  60. *** light.h.orig    Thu Jun 18 15:15:04 1992
  61. --- light.h    Thu Jun 18 15:18:16 1992
  62. ***************
  63. *** 43,50 ****
  64.   
  65.   typedef struct {
  66.       struct Geom *obj;    /* Pointer to cached object */
  67. !     RSMatrix trans;    /* World-to-object transformation */
  68.       char dotrans;        /* TRUE if above trans is non-identity */
  69.   } ShadowCache;
  70.   
  71.   typedef struct {
  72. --- 43,52 ----
  73.   
  74.   typedef struct {
  75.       struct Geom *obj;    /* Pointer to cached object */
  76. !     RSMatrix trans;        /* World-to-object transformation */
  77.       char dotrans;        /* TRUE if above trans is non-identity */
  78. +     char transp;        /* TRUE if parts of the object that */
  79. +                 /* have no surface will be transparent */
  80.   } ShadowCache;
  81.   
  82.   typedef struct {
  83. *** shadow.c.orig    Mon Jun 15 18:37:18 1992
  84. --- shadow.c    Thu Jun 18 17:25:51 1992
  85. ***************
  86. *** 94,107 ****
  87.                */
  88.               if (intersect(cp->obj, &tmpray, &hitlist,
  89.                   SHADOW_EPSILON, &s)) {
  90. !                 CacheHits++;
  91. !                 return TRUE;
  92.               }
  93.           } else if (IsAggregate(cp->obj)) {
  94.               if ((*cp->obj->methods->intersect)(cp->obj->obj,
  95.                   &tmpray, &hitlist, SHADOW_EPSILON, &s)) {
  96. !                 CacheHits++;
  97. !                 return TRUE;
  98.               }
  99.           } else if ((*cp->obj->methods->intersect)(cp->obj->obj,
  100.                       &tmpray, SHADOW_EPSILON, &s)) {
  101. --- 94,118 ----
  102.                */
  103.               if (intersect(cp->obj, &tmpray, &hitlist,
  104.                   SHADOW_EPSILON, &s)) {
  105. !                 /* Cannot use GetShadingSurf() */
  106. !                 for (sptr = 0, i = 0; i < hitlist.nodes; i++)
  107. !                     if (sptr = hitlist.data[i].obj->surf)
  108. !                         break;
  109. !                 if (sptr && sptr->transp < EPSILON || sptr == 0 && !cp->transp) {
  110. !                         CacheHits++;
  111. !                         return TRUE;
  112. !                 }
  113.               }
  114.           } else if (IsAggregate(cp->obj)) {
  115.               if ((*cp->obj->methods->intersect)(cp->obj->obj,
  116.                   &tmpray, &hitlist, SHADOW_EPSILON, &s)) {
  117. !                 for (sptr = 0, i = 0; i < hitlist.nodes; i++)
  118. !                     if (sptr = hitlist.data[i].obj->surf)
  119. !                         break;
  120. !                 if (sptr && sptr->transp < EPSILON || sptr == 0 && !cp->transp) {
  121. !                         CacheHits++;
  122. !                         return TRUE;
  123. !                 }
  124.               }
  125.           } else if ((*cp->obj->methods->intersect)(cp->obj->obj,
  126.                       &tmpray, SHADOW_EPSILON, &s)) {
  127. ***************
  128. *** 252,257 ****
  129. --- 263,269 ----
  130.       HitNode *np;
  131.       int i, n;
  132.       extern long ShadowOptions;
  133. +     int gotsurf = FALSE;
  134.   
  135.       i = 0;
  136.   
  137. ***************
  138. *** 295,300 ****
  139. --- 307,316 ----
  140.           i++;
  141.           np++;
  142.       }
  143. +     /*
  144. +      * DefaultSurface is not transparent
  145. +      */
  146. +     cache->transp = FALSE;
  147.       cache->dotrans = FALSE;
  148.       while (i < hitlist->nodes -1) {
  149.           if (np->obj->trans) {
  150. ***************
  151. *** 309,314 ****
  152. --- 325,335 ----
  153.                       &cache->trans);
  154.                   cache->dotrans = TRUE;
  155.               }
  156. +         }
  157. +         if (!gotsurf && np->obj->surf) {
  158. +             gotsurf = TRUE;
  159. +             if (np->obj->surf->transp >= EPSILON)
  160. +                 cache->transp = TRUE;
  161.           }
  162.           i++;
  163.           np++;
  164.  
  165.